package news.config;

import news.model.CommonResult;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.NoHandlerFoundException;

@RestControllerAdvice
public class GlobalExceptionHandler {
  
    /**
     * 针对其他异常处理
     */
    @ExceptionHandler(Exception.class)
    public CommonResult globalException(Exception e) {
        CommonResult commonResult = new CommonResult(500,e.getMessage());
        e.printStackTrace();
        return commonResult;
    }
}
